package cn.ekuma.epos.datalogic.define.dao.crm.service;

import cn.ekuma.data.dao.BaseDAO;
import cn.ekuma.epos.db.table.crm.service.I_TelephoneFollow;

import com.openbravo.bean.AppUser;
import com.openbravo.bean.crm.service.Telephone;
import com.openbravo.bean.crm.service.TelephoneFollow;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;

public class TelephoneFollowDAO extends BaseDAO<TelephoneFollow> {

	public TelephoneFollowDAO(I_Session s) {
		super(s);
	}

	@Override
	public TableDefinition getTable() {
		return new TableDefinition( s,
                "TELEPHONEFOLLOW",
                new Field[]{
                    new Field(I_TelephoneFollow.ID, Datas.STRING, Formats.STRING),
                    new Field(I_TelephoneFollow.CALLTIME,Datas.TIMESTAMP, Formats.TIMESTAMP),
                    new Field(I_TelephoneFollow.USERID,Datas.STRING, Formats.STRING,AppUser.class),
                    new Field(I_TelephoneFollow.PRIORITY,Datas.INT, Formats.INT),
                    new Field(I_TelephoneFollow.STATE,Datas.STRING, Formats.STRING),
                    new Field(I_TelephoneFollow.NEXTTIME,Datas.TIMESTAMP, Formats.TIMESTAMP),
                    new Field(I_TelephoneFollow.RELATIONID,Datas.STRING, Formats.STRING),
                    new Field(I_TelephoneFollow.RELATIONMAN,Datas.STRING, Formats.STRING),
                    new Field(I_TelephoneFollow.MEMO,Datas.STRING, Formats.STRING),
                    new Field(I_TelephoneFollow.STATEOBJECTID,Datas.STRING, Formats.STRING,Telephone.class),
                },
                new int[]{0});
	}

	@Override
	public void writeInsertValues(DataWrite dp, TelephoneFollow obj)
			throws BasicException {
		dp.setString(1,obj.getId());
		dp.setTimestamp(2,obj.getCallTime());
		dp.setString(3,obj.getUserId());
		dp.setInt(4,obj.getPriority());
		dp.setString(5,obj.getState());
		dp.setTimestamp(6,obj.getNextTime());
		dp.setString(7,obj.getRelationID());
		dp.setString(8,obj.getRelationMan());
		dp.setString(9,obj.getMemo());
		dp.setString(10,obj.getStateObjectId());
	}

	@Override
	public Class getSuportClass() {
		return TelephoneFollow.class;
	}

	@Override
	public TelephoneFollow readValues(DataRead dr, TelephoneFollow obj)
			throws BasicException {
		if(obj==null)
			obj=new TelephoneFollow();
		obj.setId(dr.getString(1));
		obj.setCallTime(dr.getTimestamp(2));
		obj.setUserId(dr.getString(3));
		obj.setPriority(dr.getInt(4));
		obj.setState(dr.getString(5));
		obj.setNextTime(dr.getTimestamp(6));
		obj.setRelationID(dr.getString(7));
		obj.setRelationMan(dr.getString(8));
		obj.setMemo(dr.getString(9));
		obj.setStateObjectId(dr.getString(10));
		return obj;
	}

}
